/**
 * Created by JasonChou on 16/6/2.
 */
window.host = location.origin + location.pathname + location.search + '#!/';//   'http://192.168.199.203:3000/?1#!/';
window.api = 'http://api.wenshendaka.com/';

window.refreshCache = {};

window.pageType = {
  NATIVE: 1,
  H5: 2,
  THREE_PARTY: 3
};

window.log = function () {
  console.log(arguments);

  // try {
  //   $.ajax({
  //     url: 'http://192.168.199.203:3003/log',
  //     dataType: 'jsonp',
  //     data: {content: arguments},
  //     success: function (res) {
  //       console.log(res);
  //     }
  //   });
  // } catch (e) {
  //
  // }
};

window.browser = {
  init: function () {
    window.onscroll = function () {
      var t = window.scrollY;//document.body.scrollTop;
      bridge.onScroll(0, t);
    }
  },
  go: function (url, type) {
    if (type == pageType.H5)
      location.href = url;
    else if (type == pageType.THREE_PARTY)
      location.href = url;
    else if (type == pageType.NATIVE) {
      alert('需要安装客户端！');
    }
  },

  toast: function (res) {
    alert(res);
  },
  close: function () {
    history.back();
  },

  ls_get: function (key, cb) {
    cb(localStorage[key]);
  },

  ls_set: function (key, value) {
    localStorage[key] = value;
  },

  ls_pop: function (key, cb) {
    var res = localStorage[key];
    delete localStorage[key];
    cb(res);
  },
};
